home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12778 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  54 lines

  1. Path: newshub.cts.com!not-for-mail
  2. From: baz@cts.com (Barbara Anderson-Zayat)
  3. Newsgroups: comp.sys.sgi.bugs,comp.sys.sgi.apps,comp.sys.sgi.misc,comp.lang.c++
  4. Subject: Re: C++ template "already defined" error - any ideas?
  5. Followup-To: comp.sys.sgi.bugs,comp.sys.sgi.apps,comp.sys.sgi.misc,comp.lang.c++
  6. Date: 21 Mar 1996 17:07:32 GMT
  7. Organization: CTS Network Services (CTSNET), San Diego, CA
  8. Message-ID: <4is2ck$g7b@news3.cts.com>
  9. References: <4in2p7$27b@calvin.st-and.ac.uk>
  10. NNTP-Posting-Host: crash-i2.cts.com
  11.  
  12. Peter Foldiak (pf2@st-andrews.ac.uk) wrote:
  13.  
  14. : When I try to compile the files below on a SG Indy (Irix 5.3) I get the
  15. : following error:
  16.  
  17. : ----
  18. : % CC main.c list.c
  19. : main.c:
  20. : "list.h", line 1: error(3328): class template "list" has already been
  21. : defined
  22. :   template<class T> class list {
  23. :                           ^
  24. : 1 error detected in the compilation of "main.c".
  25. : list.c:
  26. : %
  27. : ----
  28. : (By the way, how do I find out what error(3328) is in more detail?)
  29.  
  30. : If I concatenate list.c and main.c into a file called listmain.c,
  31. : and compile with
  32. : % CC listmain.c
  33. : %
  34. : the error message disapprears! So I guess it has something to do
  35. : with the bits being in separate files.
  36. : Also, if the files contain no templates there is no error.
  37. : Could anyone please help? Any ideas?
  38. : Is there something special with including headrers when I use templates?
  39. : Thanks!
  40.  
  41.  
  42. Try including this in list.h ...
  43.  
  44. #ifdef __LIST_H_
  45. #define __LIST_H_
  46.  
  47. // contents of list.h
  48.  
  49. #endif
  50.  
  51.  
  52. It sounds like somehow your list.h is getting included twice.
  53.  
  54.